package com.pms.mapper;

import com.github.pagehelper.Page;
import com.pms.dto.OwnerPageQueryDTO;
import com.pms.entity.Owner;
import com.pms.vo.OwnerPageQueryVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OwnerMapper {

    /**
     * 根据业主名字查询
     * @param ownerName
     * @return
     */
    @Select("select * from owner where name=#{ownerName}")
    Owner getByOwnerName(String ownerName);

    /**
     * 动态新增
     * @param owner
     */
    void insert(Owner owner);

    /**
     * 业主分页查询
     * @param ownerPageQueryDTO
     * @return
     */
    Page<OwnerPageQueryVO> pageQuery(OwnerPageQueryDTO ownerPageQueryDTO);

    /**
     * 根据id查询业主
     * @param id
     * @return
     */
    @Select("select * from owner where id=#{id};")
    Owner getById(Integer id);

    /**
     * 根据id删除
     * @param id
     */
    @Delete("delete from owner where id=#{id}")
    void delete(Integer id);

    /**
     * 修改业主信息(手机号)
     * @param owner
     */
    void update(Owner owner);

    /**
     * 根据业主姓名和手机号查询业主信息
     * @param ownerName
     * @param phone
     * @return
     */
    @Select("select * from owner where name=#{ownerName} and phone=#{phone}")
    Owner getByNameAndPhone(String ownerName, String phone);

    /**
     * 统计总数
     * @return
     */
    @Select("select count(*) from owner")
    Integer count();
}
